package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Order;
import com.itheima.reggie.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "APP用户订单")
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    // 用户下单
    @ApiOperation(value = "用户下单")
    @PostMapping("/submit")
    public ResultInfo submitOrder(@RequestBody Order order) {

        orderService.submit(order);

        return ResultInfo.success();
    }


    // 历史订单 和 个人页面最新订单接口 和 查看订单是同一个接口
    @ApiOperation(value = "历史订单")
    @GetMapping("/userPage")
//    public ResultInfo userPage( @RequestParam(name = "page", defaultValue = "1") Integer pageNum,
//                                @RequestParam(name = "pageSize", defaultValue = "5") Integer pageSize){

    public ResultInfo userPage( Integer page, Integer pageSize){

        Page<Order> orderList = orderService.orderSet(page,pageSize);

        return ResultInfo.success(orderList);
    }



}
